package com.sinosoft.sinopay.apiservice.wechat.util;

import java.io.IOException;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

/**
 * 
 * 【微信http工具】
 * @Description: 微信http工具
 * @author chihouliang
 * @date 2016年6月22日 下午2:05:10 
 * @version V1.0
 */
public class WechatHttpUtil {
    
    /**
     * get请求 
     * @Title: sendGet 
     * @Description: TODO
     * @param url
     * @return
     */
    public static String sendGet(String url){
        String result = "";
        CloseableHttpClient httpClient =  HttpClients.createDefault();
        HttpGet get = new HttpGet(url);
        
        try {
            HttpResponse httpResponse = httpClient.execute(get);
            StatusLine status =  httpResponse.getStatusLine();
            if(200==status.getStatusCode()){
                HttpEntity httpEntity = httpResponse.getEntity();
                result = EntityUtils.toString(httpEntity);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }
}
